@extends('admin')

@section('content')

    <p class="mb10">
        <a href="{{url('admin/rbac/edituser/')}}" class="btn J_dialog" title="发布"><span class="add"></span>发布</a>
    </p>

    <div class="h_a">搜索</div>
    <div class="search_type cc mb10">
        <form action="{{url('admin/rbac')}}" method="get" class="search_form">
            <label for="search_title">标题：</label><input type="text" name="name" value="" id="search_title" class="input length_2 mr10"/>
            <button type="submit" class="btn">提交查询</button>
            <button type="button" id="excelOutput">Excel导出</button>
        </form>

    </div>

    <div class="table_list">
        <div id="data_list">
            <table class="items">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>名字</th>
                    <th>手机号</th>
                    <th>身份证号</th>
                    <th>角色</th>
                    <th>注册时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {{count($items)}}
                    @if( count($items) )
                        @foreach ($items as $item)
                            <tr>
                                <td>{{$item->id}}</td>
                                <td>{{$item->name}}</td>
                                <td>{{$item->mobile}}</td>
                                <td>{{$item->idNo}}</td>
                                <td>{{$item->display_name}}</td>
                                <td>{{$item->created_at}}</td>
                                <td>
                                    <a href="{{url('admin/rbac/edituser/'.$item->id)}}" title="编辑{{$item->name}}" class="mr10 J_dialog">[编辑]</a>
                                    <a href="{{url('admin/rbac/delete/'.$item->id)}}" class="mr10 J_ajax_del">[删除]</a>
                                </td>
                            </tr>
                        @endforeach
                    @endif
                </tbody>
            </table>
        </div>

        {{--<div class="summary">--}}
            {{--共有 {{$items->total()}} 条数据--}}
        {{--</div>--}}
        {{--@if ($items->hasPages())--}}
            {{--<div class="pager">--}}
                {{--{!! $items->appends($appends)->render() !!}--}}
            {{--</div>--}}
        {{--@endif--}}
    {{--</div>--}}

@stop
        @section('js')
            @parent
        <script type="text/javascript" language="JavaScript">
            $(function() {
                //用户信息excel导出实现
                $('#excelOutput').click(function() {
                    var json = {
                        "subject": 'user',
                        "_token": '{{csrf_token()}}'
                    };
                    $.post('/admin/excel/excel-output', json, function (data) {
                        if (data.indexOf('excel') == -1) {
                            alert(data);
                        } else {
                            var iframe = document.createElement("iframe");
                            iframe.src = "http://" + document.location.host + "/" + data;
                            iframe.style.display = "none";
                            document.body.appendChild(iframe);

                        }

                    });
                });
            });
        </script>
@stop